package main

import "fmt"

type Employee struct {
	name   string
	salary float64
}
type Human struct {
	name, phone string
	age         int
}

type Employee1 struct {
	salary float64
	Human
}

type Student2 struct {
	Human
	school string
}

func main() {

	//方法和函数的区别
	emp := Employee{"go", 5000}
	printEmployeeFunc(emp)
	emp.printEmployee()
	emp.changeEmployee("java")
	emp.printEmployee()
	printEmployeeFunc(emp)

	//方法继承
	student2 := Student2{Human{"万祥", "13378858817", 15}, "威信一中"}
	emp1 := Employee1{6000, Human{"go", "456789654567", 30}}
	student2.sayHi()
	emp1.sayHi()
}

//定义了1个方法
func (e Employee) printEmployee() {
	fmt.Println("name ", e.name, " salary ", e.salary)
}

//定义一个函数
func printEmployeeFunc(e Employee) {
	fmt.Println("name ", e.name, " salary ", e.salary)
}

//定义一个指针方法
func (e *Employee) changeEmployee(name string) {
	e.name = name
}

func (h *Human) sayHi() {
	fmt.Printf("名字 == %s \n", h.name)
}

// 方法重写
func (s Student2) sayHi() {
	fmt.Printf("名字 == %s , 学校 == %s \n ", s.name, s.school)
}
